package com.somnus.androidkotlindemo

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.somnus.androidkotlindemo.activity.BaseRecyclerAdapterActivity
import com.somnus.androidkotlindemo.activity.KotlinUIActivity
import com.somnus.androidkotlindemo.databinding.DatabindingActivity
import com.somnus.androidkotlindemo.kt.ktColor
import com.somnus.androidkotlindemo.kt.ktStartActivity
import kotlinx.android.synthetic.main.activity_kotlin_ui.*
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)


//        tv_hello.text = "Hello Kotlin"
//        tv_hello.text
        /***
         * 1、 text1.text = (Editable e)    : text1.text = Editable.Factory().newEditable(message)
         * 2、 text1.setText(CharSequence text)
         */

        /**
        tv_hello.setOnClickListener { v: View -> Toast.makeText(this, "hello , kotlin", Toast.LENGTH_SHORT).show() }
         */

        /**
         *   tv_hello.setOnClickListener {
        Toast.makeText(this,"hello,Kotlin",Toast.LENGTH_SHORT).show()
        }
         */
//        tv_hello.setOnClickListener { this }
        button_ui.setOnClickListener {
            startActivity(intent.setClass(this@MainActivity, KotlinUIActivity::class.java))
        }
        //模拟崩溃重启
//        button_crach.setOnClickListener {
//            tv_hello.text = "Hello Kotlin"
//            9 / 0
//        }

        button_databinding.setOnClickListener({
            ktStartActivity<DatabindingActivity>()
//            startActivity(intent.setClass(this@MainActivity, DatabindingActivity::class.java))
        })

    }


}
